package swe.servlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import swe.article.ArticleDAO;
import swe.article.ArticleManager;
import swe.user.UserDAO;
import swe.user.UserManager;


public class Singleton implements ServletContextListener {

		public void contextInitialized(ServletContextEvent e) {
			try {
				ServletContext sc = e.getServletContext();
				ArticleDAO adao = new ArticleDAO("C:/workspace/articles.ser");
				UserDAO udao = new UserDAO("C:/workspace/user.ser");
				UserManager uManager = new UserManager(udao);
				ArticleManager aManager = new ArticleManager(adao);
				System.out.println("in the listener");
				sc.setAttribute("adao", adao);
				sc.setAttribute("udao", udao);
				sc.setAttribute("uManager", uManager);
				sc.setAttribute("aManager", aManager);
			} catch (Exception exp) {
				exp.printStackTrace();
			}

		}

		public void contextDestroyed(ServletContextEvent e) {
		}
	}



